import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

import { NestExpressApplication } from '@nestjs/platform-express';
import * as cookieParser from 'cookie-parser';
import * as session from 'express-session';
async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule);
  const port = process.env.PORT ?? 3000;
  // app.useStaticAssets(join(__dirname, '..', 'public'));
  app.useStaticAssets('public', {
    prefix: '/static/',
  });
  app.setBaseViewsDir('views');
  app.setViewEngine('ejs');
  app.use(cookieParser('dasdasdsad'));
  app.use(
    session({
      secret: 'cat',
      cookie: {
        maxAge: 60000,
        httpOnly: true,
      },
      rolling: true, // 每次重新获取cookie
    }),
  );
  await app.listen(port);
  console.log('启动端口', port);
}
bootstrap();
